package com.fau.ss.action.index;

import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Namespace;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.springframework.context.annotation.Scope;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.stereotype.Controller;

import com.fau.ss.action.PublicAction;
import com.fau.ss.entity.MedicalAdmin;
import com.fau.ss.entity.MedicalSsPurchase;
import com.opensymphony.xwork2.ModelDriven;

/**
 * @desc 购药类别统计Action
 * @author liy
 * @datetime 2014年11月3日,下午4:43:26
 */
@Controller
@Scope("prototype")
@ParentPackage("default")
@Namespace("/")
public class MedicineTypeStaAction extends PublicAction implements ModelDriven<MedicalSsPurchase>{

	private static final long serialVersionUID = -4743165361566354326L;

	private MedicalSsPurchase purchase = new MedicalSsPurchase();
	
	/**
	 * @desc 进入药品类别统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年10月30日,下午9:54:13
	 */
	@Action(value = "medicine_type_init", results = {@Result(name = SUCCESS, location = "medicine_type_init.jsp")})
	public String init(){
		return SUCCESS;
	}
	
	/**
	 * @desc 进入年龄段统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年11月1日,上午11:37:17
	 */
	@Action(value = "medicine_type_age", results = {@Result(name = SUCCESS, location = "medicine_type_age.jsp")})
	public String age(){
		return SUCCESS;
	}
	
	/**
	 * @desc 年龄段统计饼状图
	 * @return String
	 * @author dangjh
	 * @datetime 2014年11月18日,下午5:20:32
	 */
	@Action(value = "medical_type_age_view")
	public String ageView(){
		HttpServletResponse response = ServletActionContext.getResponse();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		map = this.baseAllService.getMedicineTypeService().countByAge(purchase, admin);
		formatJSON(response, map);
		return null;
	}
	
	/**
	 * @desc 进入性别统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年11月1日,上午11:44:11
	 */
	@Action(value = "medicine_type_gender", results = {@Result(name = SUCCESS, location = "medicine_type_gender.jsp")})
	public String year(){
		return SUCCESS;
	}
	
	/**
	 * @desc 性别统计报表(饼状图)
	 * @return String
	 * @author dangjh
	 * @datetime 2014年11月12日,下午9:37:27
	 */
	@Action(value = "medicine_type_gender_view")
	public String genderView(){
		HttpServletResponse response = ServletActionContext.getResponse();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		map = this.baseAllService.getMedicineTypeService().countByGender(purchase, admin);
		formatJSON(response, map);
		return null;
	}
	
	/**
	 * @desc 进入地区统计页面
	 * @return String
	 * @author liy
	 * @datetime 2014年11月1日,下午1:36:25
	 */
	@Action(value = "medicine_type_area", results = {@Result(name = SUCCESS, location = "medicine_type_area.jsp")})
	public String area(){
		return SUCCESS;
	}

	/**
	 * @desc 地区统计报表(饼状图)
	 * @return String
	 * @author dangjh
	 * @datetime 2014年11月12日,下午9:37:27
	 */
	@Action(value = "medicine_type_area_view")
	public String areaView(){
		HttpServletResponse response = ServletActionContext.getResponse();
		MedicalAdmin admin = (MedicalAdmin) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
		map = this.baseAllService.getMedicineTypeService().countByArea(purchase, admin);
		formatJSON(response, map);
		return null;
	}
	
	@Override
	public MedicalSsPurchase getModel() {
		return purchase;
	}
}